export default [
    {
        path: '/pay',
        name: 'pay',
        component: () => import("@/pages/Pay"),
        // 路由独享守卫
        beforeEnter: (to, from, next) => {
            if (from.path == '/trade') {
                next()
            } else {
                next(false)
            }
        }
    },
    {
        path: '/trade',
        name: 'trade',
        component: () => import('@/pages/Trade'),
        //路由独享守卫
        beforeEnter: (to, from, next) => {
            if (from.path == '/shopcar') {
                next()
            } else {
                //从哪来 到哪去(如果用户手动输入改变了地址栏的值 则会直接跳转到from的path的路由)
                next(false)
            }
        }
    },
    {
        path: '/shopcar',
        name: 'shopcar',
        component: () => import('@/pages/ShopCart'),
        meta: { show: true },
    },
    {
        path: '/addshopcarsuccess',
        name: 'addshopcarsuccess',
        component: () => import('@/pages/AddCartSuccess'),
        meta: { show: true },
    },
    {
        path: '/home',
        //component右侧数值：放置的是一个箭头函数，当这个home路由被访问的时候，才会执行；
        //当用户访问当前Home的时候，我才加载Home路由组件，不访问，不加载当前Home路由组件
        component: () => import('@/pages/Home'),
        //路由元信息---控制footer显示与隐藏
        meta: { show: true },
    },
    {
        //代表params参数可有可无，务必要加上?
        path: '/search/:keyword?',
        //不管你访问不访问search，都加载search路由组件
        component: () => import('@/pages/Search'),
        meta: { show: true },
        //命名路由
        name: 'search',
        //路由也可以传递props数据，拥有三种写法
        //如果 props 被设置为 true，params参数将会被设置为组件属性
        // props:true,
        // props:{a:1,b:2}
        props: (route) => ({ keyWord: route.params.keyWord, k: route.query.k })

    },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/pages/Login'),
        meta: { show: false }
    },
    {
        path: '/register',
        component: () => import('@/pages/Register'),
        meta: { show: false }
    },
    {
        path: '/detail/:id',
        component: () => import('@/pages/Detail'),
        meta: { show: true }
    },
    // 重定向
    {
        path: '/',
        redirect: '/home'
    },
]